# encoding: UTF-8
# user：admin at 2018/11/2

import sqlite3

class OprationSQLite():
    def __init__(self):
        self.SQLITE_FILE='db/home_db.db'
        self.SQLITE_TABLE='t_fundall'

    def DeleteTable(self):
        try:
            conn=sqlite3.connect(self.SQLITE_FILE)
            cur=conn.cursor()
            delete_sql="delete from {0} ".format(self.SQLITE_TABLE)
            cur.execute(delete_sql)

            conn.commit()
            return True,'OK'

        except Exception as errMessage:
            return False,errMessage
        # finally:
            # cur.close()
            # conn.close()

    def SelectTalbe(self):
        try:
            conn=sqlite3.connect(self.SQLITE_FILE)
            cur=conn.cursor()
            #select_sql="select * from {0} where zqdm='{1}'".format(self.SQLITE_TABLE,'004314')
            select_sql = "select zqdm,zqmc,zqurl,fdate,dwjz,ljjz,rzzl from {0}  limit 0,10 ".format(self.SQLITE_TABLE)
            cur.execute(select_sql)

            return True,cur.fetchall()

        except Exception as errMessage:
            return False,errMessage
